package io.github.hadyang.leetcode;

/**
 * @author haoyang.shi
 * @date 2020-02-23
 */
public class ListNode {
  public int val;
  public ListNode next;

  public ListNode(int val) {
    this.val = val;
  }

  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append(val);
    ListNode cursor = this.next;

    while (cursor != null) {
      builder.append("->").append(cursor.val);
      cursor = cursor.next;
    }

    return builder.toString();
  }
}
